package com.sunwayworld.basemodule.rm.equipment.repair.resource.impl;

import com.sunwayworld.basemodule.rm.equipment.repair.bean.LimsEquiptRepairBean;
import com.sunwayworld.basemodule.rm.equipment.service.LimsEquipmentService;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.restful.data.RestValidationResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sunwayworld.basemodule.rm.equipment.repair.resource.LimsEquiptRepairResource;
import com.sunwayworld.basemodule.rm.equipment.repair.service.LimsEquiptRepairService;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogModule;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

import java.util.List;

@LogModule("设备维修表")
@RestController
@GikamBean
public class LimsEquiptRepairResourceImpl implements LimsEquiptRepairResource {

    @Autowired
    private LimsEquiptRepairService limsEquiptRepairService;

    @Override
    public LimsEquiptRepairService getService() {
        return limsEquiptRepairService;
    }

    @Autowired
    private LimsEquipmentService limsEquiptService;

    public LimsEquipmentService getLimsEquiptService() {
        return limsEquiptService;
    }

    @Log(value = "新增设备维修表", type = LogType.INSERT)
    @Override
    @RequestMapping(method = RequestMethod.POST)
    public Long insert(RestJsonWrapperBean wrapper) {
        return getService().insert(wrapper);
    }

    @Log(value = "验证输入字符是否是中文", type = LogType.VALIDATE)
    @Override
    public RestValidationResultBean validateChineseValue(RestJsonWrapperBean wrapper, String columnName, String columnValue) {
        return getService().validateChineseValue(wrapper, columnName, columnValue);
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.PROCESS_COMPLETE)
    public void completeTask(RestJsonWrapperBean wrapper) {
        this.getService().updateEquiptStatus(wrapper);
        this.getService().completeTask(wrapper);
    }

}
